<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.css"  rel="stylesheet">
<link href="css/bootstrap-theme.css"  rel="stylesheet">

<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script> 
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> 
<script type="text/javascript" charset="utf-8" src="js/bootstrap.js"></script>
<script type="text/javascript" charset="utf-8" src="js/ip.js"></script>
<script type="text/javascript" charset="utf-8" src="js/plugins.js"></script>
<style>
	 
	@media screen and (max-width: 980px) {
		 
	 }

	/* Small devices (tablets, 768px and up) */
	@media screen and (max-width: 700px) {
		 
	 }
	
	/* Medium devices (desktops, 992px and up) */
	@media screen and (max-width: 480px) {
		 
	  }
	
	/* Large devices (large desktops, 1200px and up) */
	
</style>
</head>
<body>
	<div class="container" id="context">
    		<div class="row" style="height:100%">
            	  <div class="col-md-12" style="background-color:rgb(254,157,52);height:8%;font-family:微软雅黑;font-size:20px" >
                 		账号注册
                   
           		 </div>
                  <div class="col-md-12" style="background-color:rgb(236,236,236);height:92%;">
                  		<div class="center-block" >
                       		 <br/>
                            <div class="input-group">
                              <span class="input-group-btn">
                                <button class="btn btn-default" type="button">电子邮箱</button>
                              </span>
                              <input type="text" class="form-control" id="email">
                            </div><!-- /input-group -->
                            <br/>
                            
                            <div class="input-group">
                              <span class="input-group-btn">
                                <button class="btn btn-default" type="button">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</button>
                              </span>
                              <input type="password" class="form-control" id="password">
                            </div><!-- /input-group -->
                            <br/>
                             <!--  <div class="input-group">
                              <span class="input-group-btn">
                                <button class="btn btn-default" type="button">确认密码</button>
                              </span>
                              <input type="password" class="form-control" id="confirmPassword">
                            </div>
                            <br/> 
                              <div class="input-group">
                              <span class="input-group-btn">
                                <button class="btn btn-default" type="button">电子邮箱</button>
                              </span>
                              <input type="text" class="form-control" id="email">
                            </div>
                            <br/>
                             <!--   <div class="input-group">
                              <span class="input-group-btn">
                                <button class="btn btn-default" type="button">手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机</button>
                              </span>
                              <input type="text" class="form-control" id="phone">
                            </div> 
                            <br/>-->
                          
                            <br/>
                     		<button type="button" class="btn btn-default  btn-block" onClick="emailValid()">注册</button>
                              <br/>
                        </div>
                    


           		 </div>
            </div>
    </div>
</body>
<script>
	var cheight=document.documentElement.clientHeight;
	var context=document.getElementById("context");
	context.style.height=cheight+"px";
	function emailValid(){
		var name=document.getElementById("email").value;
		var data={"name":"userEmail","value":name};
		$.ajax({
			"url":IP.main+IP.user+"!validArgs",
			"data":data,
			"type":"post",
			"dataType":"json",
			"success": function(json){
				plugs.box.show();
				console.log("valid:"+json);
				console.log("valid:"+json.state);
				if(json&&json.state==true){
					reg();
				}else{
					plugs.box.hidden();
					alert("对不起，当前邮箱已经被注册。");
					
				}
			},
			"error":function(json){
				plugs.box.hidden();
				console.log("error:"+json);
			}
		});
		
	}
	
	function reg(){
		plugs.box.show();
		var name=document.getElementById("email").value;
		var password=document.getElementById("password").value;
		//var email=document.getElementById("email").value;
		//var phone=document.getElementById("phone").value;
		//var data={"name":name,"password":password,"email":email,"phone":phone};
		var data={"user.passWord":password,"user.userEmail":name,"systeminfo":"system:"+device.platform+"  "+device.version+",version:1.0,uuid:"+device.uuid};
		$.ajax({
			"url":IP.main+IP.user+"!reg",
			"data":data,
			"type":"post",
			"success": function(json){
				plugs.box.hidden();
				console.log("reg:"+json);
				if(json&&json.state!=false){
					alert("欢迎您加入篮球俱乐部.");
					window.location.href="./main.html"
				}
			},
			"error":function(json){
				plugs.box.hidden();
				console.log("error:"+json);
			}
		});
	}
	
</script>
</html>